<template>
	<view class="resume-edit-container">
		<nav-header title="编辑简历"></nav-header>

		<view class="content" :style="{ paddingTop: statusBarHeight + 44 + 'px' }">
			<!-- Dynamically render resume sections based on active modules -->
			<block v-for="module in sortedActiveModules" :key="module.modelName">
				<!-- Personal Info Section -->
				<view v-if="module.modelName === '个人信息'" class="resume-section personal-section"
					@click="navigateToModule('个人信息')">
					<view class="section-header">
						<text class="section-title">{{ module.modelName }}</text>
						<view class="edit-btn">
							<u-icon name="arrow-right" color="#999" size="20"></u-icon>
						</view>
					</view>
					<view class="section-content">
						<view class="avatar-area">
							<image v-if="personalInfoData.avatarImageUrl" :src="personalInfoData.avatarImageUrl"
								mode="aspectFill" class="avatar"></image>
							<view v-else class="avatar-placeholder">
								<u-icon name="account" color="#ddd" size="40"></u-icon>
							</view>
						</view>
						<view class="personal-info">
							<view class="personal-row">
								<text class="info-value">{{ personalInfoData.name || '姓名' }}</text>
							</view>
							<view class="personal-row">
								<text class="info-label">电话：</text>
								<text class="info-value">{{ personalInfoData.phone || '请填写' }}</text>
							</view>
							<view class="personal-row">
								<text class="info-label">邮箱：</text>
								<text class="info-value">{{ personalInfoData.email || '请填写' }}</text>
							</view>
						</view>
					</view>
				</view>

				<!-- Job Intention Section -->
				<view v-if="module.modelName === '求职意向'" class="resume-section intention-section"
					@click="navigateToModule('求职意向')">
					<view class="section-header">
						<text class="section-title">{{ module.modelName }}</text>
						<view class="edit-btn">
							<u-icon name="arrow-right" color="#999" size="20"></u-icon>
						</view>
					</view>
					<view class="section-content">
						<view class="intention-info" v-if="hasJobIntention">
							<view class="intention-row">
								<text class="intention-item">求职岗位：{{ jobData.jobPosition || '未填写' }}</text>
							</view>
							<view class="intention-row">
								<text class="intention-item">意向城市：{{ jobData.intendedCity }}</text>
							</view>
							<view class="intention-row">
								<text class="intention-item">求职类型：{{ jobData.jobType }}</text>
							</view>
							<view class="intention-row">
								<text class="intention-item">期望薪资：{{ jobData.expectedSalary }}</text>
							</view>
						</view>
						<view class="empty-content" v-else>
							<text class="placeholder-text">请填写求职岗位</text>
						</view>
					</view>
				</view>

				<!-- Education Section -->
				<view v-if="module.modelName === '教育经历'" class="resume-section education-section">
					<view class="section-header">
						<text class="section-title">{{ module.modelName }}</text>
						<view class="edit-btn" @click="navigateToModule('教育经历')">
							<u-icon name="plus" color="#999" size="20"></u-icon>
						</view>
					</view>
					<view class="section-content">
						<view class="education-info" v-if="hasEducation">
							<view class="education-row" v-for="(edu, index) in educationDataArr" :key="index"
								@click="navigateToModuleInfo('教育经历',edu.id)">
								<view class="education-school">{{ edu.schoolName }}</view>
								<view class="education-details">
									<text class="education-major">{{ edu.major }}</text>
									<text class="education-degree">{{ edu.educationalBackground }}</text>
									<text class="education-time">{{ edu.startDate }} - {{ edu.endDate || '至今' }}</text>
									<text class="education-time maxHeight">{{ edu.academicPerformance }}</text>
								</view>
							</view>
						</view>
						<view class="empty-content" v-else>
							<text class="placeholder-text">学校</text>
							<text class="placeholder-text">专业：请输入专业名称</text>
							<text class="placeholder-text">学历：请选择</text>
							<text class="placeholder-text">开始时间 - 结束时间</text>
							<text class="placeholder-text">请输入学习成绩、主修课程等信息。如未填写，AI将自动生成此内容。</text>
						</view>
					</view>
				</view>

				<!-- campusExperience Section -->
				<view v-if="module.modelName === '校园经历'" class="resume-section education-section">
					<view class="section-header">
						<text class="section-title">{{ module.modelName }}</text>
						<view class="edit-btn" @click="navigateToModule('校园经历')">
							<u-icon name="plus" color="#999" size="20"></u-icon>
						</view>
					</view>
					<view class="section-content">
						<view class="education-info" v-if="hasCampus">
							<view class="education-row" v-for="(campus, index) in campusDataArr" :key="index"
								@click="navigateToModuleInfo('校园经历',campus.id)">
								<view class="education-school">{{ campus.experienceName }}</view>
								<view class="education-details">
									<text class="education-major">{{ campus.position }}</text>
									<text class="education-time">{{ campus.startDate }} - {{ campus.endDate || '至今' }}</text>
									<text class="education-time maxHeight">{{ campus.experienceDescription }}</text>
								</view>
							</view>
						</view>
						<view class="empty-content" v-else>
							<text class="placeholder-text">学校</text>
							<text class="placeholder-text">专业：请输入专业名称</text>
							<text class="placeholder-text">学历：请选择</text>
							<text class="placeholder-text">开始时间 - 结束时间</text>
							<text
								class="placeholder-text">可填写在校参与的学生组织、社团活动、学生会职务、班干职务、竞赛经历，例："学生会干部、学习委员、创新创业大赛"；重点强调个人职责和成果；如果不填则由AI根据经历自动撰写。</text>
						</view>
					</view>
				</view>

				<!-- Work Experience Section -->
				<view v-if="module.modelName === '工作经历'" class="resume-section work-section">
					<view class="section-header">
						<text class="section-title">{{ module.modelName }}</text>
						<view class="edit-btn" @click="navigateToModule('工作经历')">
							<u-icon name="plus" color="#999" size="20"></u-icon>
						</view>
					</view>
					<view class="section-content">
						<view class="work-info" v-if="hasWork">
							<view class="work-row" v-for="(work, index) in workExperiencesDataArr" :key="index"
								@click="navigateToModuleInfo('工作经历',work.id)">
								<view class="work-company">{{ work.companyName }}</view>
								<view class="work-details">
									<text class="work-position">工作岗位：{{ work.job }}</text>
									<text class="work-time">{{ work.startDate }} - {{ work.endDate || '至今' }}</text>
									<text class="work-time maxHeight">{{ work.jobDescription }}</text>
								</view>
							</view>
						</view>
						<view class="empty-content" v-else>
							<text class="placeholder-text">公司</text>
							<text class="placeholder-text">工作岗位：请输入岗位名称</text>
							<text class="placeholder-text">开始时间 - 结束时间</text>
							<text
								class="placeholder-text">可填写企业经历、创业经历、政府或机构经历、非营利组织工作经历，例："产品经理、开发工程师、财务助理"；主要简述工作内容、岗位职责及取得的工作成果。如果不填则由AI根据职位自动撰写。</text>
						</view>
					</view>
				</view>

				<!-- 实习经历 -->
				<view v-if="module.modelName === '实习经历'" class="resume-section work-section">
					<view class="section-header">
						<text class="section-title">{{ module.modelName }}</text>
						<view class="edit-btn" @click="navigateToModule('实习经历')">
							<u-icon name="plus" color="#999" size="20"></u-icon>
						</view>
					</view>
					<view class="section-content">
						<view class="work-info" v-if="hasInternExperiences">
							<view class="work-row" v-for="(work, index) in internExperiencesDataArr" :key="index"
								@click="navigateToModuleInfo('实习经历',work.id)">
								<view class="work-company">{{ work.companyName }}</view>
								<view class="work-details">
									<text class="work-position">实习岗位：{{ work.internshipJob }}</text>
									<text class="work-time">{{ work.startDate }} - {{ work.endDate || '至今' }}</text>
									<text class="work-time maxHeight">{{ work.internshipDescription }}</text>
								</view>
							</view>
						</view>
						<view class="empty-content" v-else>
							<text class="placeholder-text">公司</text>
							<text class="placeholder-text">工作岗位：请输入岗位名称</text>
							<text class="placeholder-text">开始时间 - 结束时间</text>
							<text
								class="placeholder-text">可填写企业经历、创业经历、政府或机构经历、非营利组织工作经历，例："产品经理、开发工程师、财务助理"；主要简述工作内容、岗位职责及取得的工作成果。如果不填则由AI根据职位自动撰写。</text>
						</view>
					</view>
				</view>

				<!-- Project Experience Section -->
				<view v-if="module.modelName === '项目经历'" class="resume-section project-section">
					<view class="section-header">
						<text class="section-title">{{ module.modelName }}</text>
						<view class="edit-btn" @click="navigateToModule('项目经历')">
							<u-icon name="plus" color="#999" size="20"></u-icon>
						</view>
					</view>
					<view class="section-content">
						<view class="project-info" v-if="hasProject">
							<view class="project-row" v-for="(project, index) in projectDataArr" :key="index"
								@click="navigateToModuleInfo('项目经历',project.id)">
								<view class="project-name">{{ project.projectName }}</view>
								<view class="project-details">
									<text class="project-role">{{ project.position }}</text>
									<text class="project-time">{{ project.startDate }} -
										{{ project.endDate || '至今' }}</text>
									<text class="project-time maxHeight">{{ project.projectDescription }}</text>
								</view>
							</view>
						</view>
						<view class="empty-content" v-else>
							<text class="placeholder-text">项目名称</text>
							<text class="placeholder-text">担任职务：请输入职务名称</text>
							<text class="placeholder-text">开始时间 - 结束时间</text>
							<text
								class="placeholder-text">可填写学术研究、在校的课堂项目、比赛项目、课外活动中或工作中的项目经历；请简述项目主题、项目背景、项目职责及项目成果。如果不填则由AI根据角色自动撰写。</text>
						</view>
					</view>
				</view>

				<!-- Skills Section -->
				<view v-if="module.modelName === '专业技能'" class="resume-section skills-section"
					@click="navigateToModule('专业技能')">
					<view class="section-header">
						<text class="section-title">{{ module.modelName }}</text>
						<view class="edit-btn">
							<u-icon name="plus" color="#999" size="20" v-if="!hasSkills"></u-icon>
							<u-icon name="arrow-right" color="#999" size="20" v-else></u-icon>
						</view>
					</view>
					<view class="section-content">
						<view class="skills-info" v-if="hasSkills">
							<view class="skills-list">
								<view class="skill-tag" v-for="(skill, index) in skillsDataArr" :key="index">
									{{ skill.skillName }}
								</view>
							</view>
						</view>
						<view class="empty-content" v-else>
							<text class="placeholder-text">请输入技能名称，建议归类描述。如未填写，AI将自动生成此内容。</text>
						</view>
					</view>
				</view>

				<!-- professional Section:资格证书 -->
				<view v-if="module.modelName === '资格证书'" class="resume-section skills-section"
					@click="navigateToModule('资格证书')">
					<view class="section-header">
						<text class="section-title">{{ module.modelName }}</text>
						<view class="edit-btn">
							<u-icon name="plus" color="#999" size="20" v-if="!hasProfessional"></u-icon>
							<u-icon name="arrow-right" color="#999" size="20" v-else></u-icon>
						</view>
					</view>
					<view class="section-content">
						<view class="skills-info" v-if="hasProfessional">
							<view class="skills-list">
								<view class="skill-tag" v-for="(professional, index) in professionalDataArr" :key="index">
									{{ professional.certificateName }}
								</view>
							</view>
						</view>
						<view class="empty-content" v-else>
							<text class="placeholder-text">请填写专业技能</text>
						</view>
					</view>
				</view>

				<!-- Self Evaluation Section -->
				<view v-if="module.modelName === '自我评价'" class="resume-section evaluation-section"
					@click="navigateToModule('自我评价')">
					<view class="section-header">
						<text class="section-title">{{ module.modelName }}</text>
						<view class="edit-btn">
							<u-icon name="arrow-right" color="#999" size="20"></u-icon>
						</view>
					</view>
					<view class="section-content">
						<view class="evaluation-info" v-if="hasSelfEvaluation">
							<text class="evaluation-text">{{ selfEvaluationData.selfEvaluationContent }}</text>
						</view>
						<view class="empty-content" v-else>
							<text class="placeholder-text">结合自己的相关行业经历、个人技能，提炼出符合职责要求的自我评价。如未填写，AI将自动生成此内容。</text>
						</view>
					</view>
				</view>

				<!-- volunteerExperiences Section -->
				<view v-if="module.modelName === '兴趣爱好'" class="resume-section evaluation-section"
					@click="navigateToModule('兴趣爱好')">
					<view class="section-header">
						<text class="section-title">{{ module.modelName }}</text>
						<view class="edit-btn">
							<u-icon name="arrow-right" color="#999" size="20"></u-icon>
						</view>
					</view>
					<view class="section-content">
						<view class="evaluation-info" v-if="hasHobbies">
							<text class="evaluation-text maxHeight">{{ hobbiesData.hobbyDescription }}</text>
						</view>
						<view class="empty-content" v-else>
							<text class="placeholder-text">兴趣爱好</text>
							<text class="placeholder-text">可简洁描述与目标岗位职责要求相关性强的兴趣爱好。如未填写，AI将自动生成此内容。</text>
						</view>
					</view>
				</view>

				<view
					v-if="!['个人信息', '求职意向', '教育经历', '工作经历', '项目经历', '专业技能', '资格证书', '自我评价', '校园经历', '实习经历', '兴趣爱好'].includes(module.modelName)"
					class="resume-section" @click="navigateToModule(module.modelName)">
					<view class="section-header">
						<text class="section-title">{{ module.modelName }}</text>
						<view class="edit-btn">
							<u-icon name="arrow-right" color="#999" size="20"></u-icon>
						</view>
					</view>
					<view class="section-content">
						<view class="empty-content">
							<text class="placeholder-text">请填写{{ module.modelName }}内容</text>
						</view>
					</view>
				</view>
			</block>

			<view class="bottomSafe">

			</view>

			<view class="bottom">
				<view class="module-manage">
					<button class="manage-btn" @click="navigateToModuleManage">模块管理</button>
				</view>
				<view class="preview-action">
					<button class="preview-btn" @click="navigateToPreview">预览简历</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup>
	import {
		ref,
		computed,
		onMounted,
		watch
	} from 'vue'
	import {
		useResumeStore
	} from '@/store/resume.js'
	import NavHeader from '@/components/nav-header.vue'
	import {
		getPersonalInfoDetail,
		getPersonalAllDetail
	} from '@/api/edit/personal.js'
	import {
		getIndexInfo
	} from '@/api/edit/index.js'
	import {
		onShow
	} from '@dcloudio/uni-app'
	import { getModelList } from '@/api/module.js'

	const resumeStore = useResumeStore()
	const statusBarHeight = ref(20)
	const personalInfoData = ref({
		id: '',
		avatarImageUrl: '', // 头像
		name: '', // 姓名
		gender: 'male', // 性别：male-男，female-女
		maritalStatus: 'isMarital', // 性别：male-男，female-女
		birthday: '', // 出生日期
		location: '', // 现住城市
		phone: '', // 手机号码
		email: '', // 邮箱
		ethnicGroup: '', // 民族
		politicalStatus: '', // 政治面貌
	})
	const selfEvaluationData = ref({
		id: '',
		selfEvaluationContent: ''
	})
	const workExperiencesDataArr = ref([])
	const educationDataArr = ref([])
	const campusDataArr = ref([])
	const jobData = ref({
		id: '',
		jobPosition: '',
		intendedCity: '',
		jobType: '',
		expectedSalary: ''
	})
	const projectDataArr = ref([])
	const skillsDataArr = ref([])
	const professionalDataArr = ref([])
	const hobbiesData = ref({
		id: '',
		hobbyDescription: ''
	})
	const internExperiencesDataArr = ref([])

	const hasWork = ref(false)
	const hasEducation = ref(false)
	const hasCampus = ref(false)
	const hasProject = ref(false)
	const hasSkills = ref(false)
	const hasProfessional = ref(false)
	const hasJobIntention = ref(false)
	const hasInternExperiences = ref(false)
	const hasSelfEvaluation = ref(false)
	const hasHobbies = ref(false)
	const sortedActiveModules = ref()

	// 获取排序后的活跃模块
	const getSortedActiveModules =() => {
		getModelList({resumeId:resumeStore.resumeId}).then(res => {
			console.log('获取模块列表', res)
			if (res.code === 200) {
				sortedActiveModules.value =  res.rows.map((item, idx) => ({
					...item,
					active: true,
					removable: item.modelName == '个人信息' ? false : true,
					sortNum: idx + 1
				}))
				// resumeStore.modules = sortedActiveModules.value
				console.log('sortedActiveModules', sortedActiveModules.value)
			}
		})
	}

	const getSortedInactiveModules =() => {
		sortedActiveModules.value = resumeStore.modules.filter(item => item.active)
	}

	// 监听模块变化
	watch(() => resumeStore.modules, (newModules) => {
		// 当模块状态改变时，重新获取数据
		getInfo()
		getSortedInactiveModules()
	}, { deep: true })

	onMounted(async () => {
		// 获取状态栏高度
		const systemInfo = uni.getSystemInfoSync()
		statusBarHeight.value = systemInfo.statusBarHeight
		
		// 加载简历数据
		await resumeStore.loadFromStorage()
		
		// 如果没有简历ID，创建新简历
		if (!resumeStore.resumeId) {
			await resumeStore.addResumeFun({
				userId: uni.getStorageSync('loginInfo').user.userId
			})
		}
		
		// 获取简历信息
		await getInfo()
		if (resumeStore.resumeId) {
			await getSortedActiveModules()
		}
	})

	onShow(async () => {
		// 每次页面显示时重新加载数据
		await resumeStore.loadFromStorage()
		await getInfo()
		// await getSortedActiveModules()
	})

	// 根据模块ID导航到对应的编辑页面
	const navigateToModule = (modelName) => {
		console.log('navigateToModule', modelName)
		console.log('resumeStore.modules', resumeStore.modules)
		// 检查模块是否激活
		const module = resumeStore.modules.find(m => m.modelName === modelName)
		if (!module || !module.active) {
			uni.showToast({
				title: '该模块未启用',
				icon: 'none'
			})
			return
		}

		// 检查是否有数据，决定是新增还是编辑
		const hasData = {
			personalInfo: !!personalInfoData.value?.id,
			selfEvaluation: !!selfEvaluationData.value?.id,
			workExperiences: workExperiencesDataArr.value.length > 0,
			educationExperiences: educationDataArr.value.length > 0,
			skills: skillsDataArr.value.length > 0,
			projectExperiences: projectDataArr.value.length > 0,
			jobIntention: !!jobData.value?.id,
			internExperiences: internExperiencesDataArr.value.length > 0,
			volunteerExperiences: !!hobbiesData.value?.id,
			professional: professionalDataArr.value.length > 0,
			campusExperience: campusDataArr.value.length > 0
		}

		// 获取当前模块的数据ID
		const getModuleId = (modelName) => {
			switch (modelName) {
				case '个人信息':
					return personalInfoData.value?.id
				case '自我评价':
					return selfEvaluationData.value?.id
				case '求职意向':
					return jobData.value?.id
				case '兴趣爱好':
					return hobbiesData.value?.id
				default:
					return null
			}
		}

		switch (modelName) {
			case '个人信息':
				resumeStore.personalInfo = personalInfoData.value
				uni.navigateTo({
					url: `/pages/resume/edit/personal${hasData.personalInfo ? '?index=' + getModuleId(modelName) : ''}`
				})
				break
			case '自我评价':
				uni.navigateTo({
					url: `/pages/resume/edit/evaluation${hasData.selfEvaluation ? '?index=' + getModuleId(modelName) : ''}`
				})
				break
			case '工作经历':
				// 工作经历是列表形式，直接进入列表页
				uni.navigateTo({
					url: '/pages/resume/edit/work'
				})
				break
			case '教育经历':
				// 教育经历是列表形式，直接进入列表页
				uni.navigateTo({
					url: '/pages/resume/edit/education'
				})
				break
			case '专业技能':
				// 技能是列表形式，直接进入列表页
				uni.navigateTo({
					url: '/pages/resume/edit/skill'
				})
				break
			case '项目经历':
				// 项目经历是列表形式，直接进入列表页
				uni.navigateTo({
					url: '/pages/resume/edit/project'
				})
				break
			case '求职意向':
				resumeStore.jobIntention = jobData.value
				uni.navigateTo({
					url: `/pages/resume/edit/intention${hasData.jobIntention ? '?index=' + getModuleId(modelName) : ''}`
				})
				break
			case '实习经历':
				// 实习经历是列表形式，直接进入列表页
				uni.navigateTo({
					url: '/pages/resume/edit/work?type=internExperiences'
				})
				break
			case '兴趣爱好':
				uni.navigateTo({
					url: `/pages/resume/edit/hobby${hasData.volunteerExperiences ? '?index=' + getModuleId(modelName) : ''}`
				})
				break
			case '资格证书':
				// 专业技能是列表形式，直接进入列表页
				uni.navigateTo({
					url: '/pages/resume/edit/skill?type=professional'
				})
				break
			case '校园经历':
				// 校园经历是列表形式，直接进入列表页
				uni.navigateTo({
					url: '/pages/resume/edit/campus'
				})
				break
			default:
				uni.showToast({
					title: '该模块暂未开放',
					icon: 'none'
				})
		}
	}

	// 根据模块ID导航到对应的编辑页面（用于编辑已有数据）
	const navigateToModuleInfo = (modelName, index) => {
		switch (modelName) {
			case '个人信息':
				uni.navigateTo({
					url: '/pages/resume/edit/personal?index=' + index
				})
				break
			case '自我评价':
				uni.navigateTo({
					url: '/pages/resume/edit/evaluation?index=' + index
				})
				break
			case '工作经历':
				uni.navigateTo({
					url: '/pages/resume/edit/work?type=workExperiences&index=' + index
				})
				break
			case '实习经历':
				uni.navigateTo({
					url: '/pages/resume/edit/work?type=internExperiences&index=' + index
				})
				break
			case '教育经历':
				uni.navigateTo({
					url: '/pages/resume/edit/education?index=' + index
				})
				break
			case '专业技能':
				uni.navigateTo({
					url: `/pages/resume/edit/skill?indexId=` + index
				})
				break
			case '项目经历':
				uni.navigateTo({
					url: '/pages/resume/edit/project?index=' + index
				})
				break
			case '求职意向':
				uni.navigateTo({
					url: '/pages/resume/edit/intention?index=' + index
				})
				break
			case '校园经历':
				uni.navigateTo({
					url: '/pages/resume/edit/campus?index=' + index
				})
				break
			case '兴趣爱好':
				uni.navigateTo({
					url: '/pages/resume/edit/hobby?index=' + index
				})
				break
			default:
				uni.showToast({
					title: '该模块暂未开放',
					icon: 'none'
				})
		}
	}

	// 导航到模块管理页面
	const navigateToModuleManage = () => {
		uni.navigateTo({
			url: '/pages/resume/module'
		})
	}

	// 导航到预览页面
	const navigateToPreview = () => {
		console.log('导航到预览页面', resumeStore.saveToStorage());

		// 先保存当前数据
		resumeStore.saveToStorage()
		console.log('resumeStore.resumeId', resumeStore.resumeId);
		// 跳转到预览页面
		uni.navigateTo({
			url: '/pages/resume/preview?id=' + resumeStore.resumeId
		})
	}

	const getInfo = () => {
		try {
			if (!resumeStore.resumeId) {
				console.log('No resumeId found')
				return
			}
			
			getIndexInfo(resumeStore.resumeId).then(async (res) => {
				console.log('获取个人信息所有详情', res)
				if (res.code === 200) {
					let data = res.data
					// 使用空对象作为默认值，防止null
					personalInfoData.value = data.personalInfo || {}
					selfEvaluationData.value = data.selfEvaluation || { id: '', selfEvaluationContent: '' }
					workExperiencesDataArr.value = data.workExperienceList || []
					internExperiencesDataArr.value = data.internshipExperienceList || []
					educationDataArr.value = data.educationExperienceList || []
					campusDataArr.value = data.campusExperienceList || []
					jobData.value = data.jobIntention || { id: '', jobPosition: '', intendedCity: '', jobType: '', expectedSalary: '' }
					projectDataArr.value = data.projectExperienceList || []
					skillsDataArr.value = data.professionalSkillList || []
					professionalDataArr.value = data.qualificationCertificateList || []
					hobbiesData.value = data.hobbies || { id: '', hobbyDescription: '' }
					
					if (data.personalInfo) {
						resumeStore.setPersonalInfo(data.personalInfo)
					}
					await checkIsHave()
				}
			}).catch(err => {
				console.error('获取简历信息失败:', err)
				uni.showToast({
					title: '获取简历信息失败',
					icon: 'none'
				})
			})
		} catch (error) {
			console.error('获取简历信息出错:', error)
			uni.showToast({
				title: '获取简历信息出错',
				icon: 'none'
			})
		}
	}

	const checkIsHave = () => {
		hasWork.value = workExperiencesDataArr.value.length > 0 ? true : false
		hasInternExperiences.value = internExperiencesDataArr.value.length > 0 ? true : false
		hasEducation.value = educationDataArr.value.length > 0 ? true : false
		hasCampus.value = campusDataArr.value.length > 0 ? true : false
		hasProject.value = projectDataArr.value.length > 0 ? true : false
		hasSkills.value = skillsDataArr.value.length > 0 ? true : false
		hasProfessional.value = professionalDataArr.value.length > 0 ? true : false
		hasJobIntention.value = !!jobData.value ? true : false
		hasSelfEvaluation.value = !!selfEvaluationData.value ? true : false
		hasHobbies.value = !!hobbiesData.value ? true : false
	}
</script>

<style lang="scss" scoped>
	.resume-edit-container {
		min-height: 100vh;
		background-color: #f8f8f8;

		.content {
			padding: 1rem;

			.resume-section {
				background-color: #ffffff;
				border-radius: .5rem;
				margin-bottom: 1rem;
				box-shadow: 0 .0625rem .25rem rgba(0, 0, 0, 0.05);
				overflow: hidden;

				.section-header {
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding: .875rem 1rem;
					border-bottom: .0625rem solid #f0f0f0;

					.section-title {
						font-size: 1rem;
						font-weight: 500;
						color: #333;
					}

					.edit-btn {
						padding: .25rem;
					}
				}

				.section-content {
					padding: .75rem 1rem;
					// height: 130px;
					overflow-y: auto;
				}

				.empty-content {
					padding: .75rem 0;
					display: flex;
					flex-direction: column;
					gap: .5rem;

					.placeholder-text {
						color: #999;
						font-size: .875rem;
						line-height: 1.5;

						&:first-child {
							font-weight: 500;
							margin-bottom: .125rem;
						}
					}
				}
			}

			.personal-section {
				.section-content {
					display: flex;
					align-items: center;

					.avatar-area {
						margin-right: 1rem;

						.avatar,
						.avatar-placeholder {
							width: 4rem;
							height: 4rem;
							border-radius: 50%;
							overflow: hidden;
						}

						.avatar {
							object-fit: cover;
						}

						.avatar-placeholder {
							background-color: #f5f5f5;
							display: flex;
							justify-content: center;
							align-items: center;
						}
					}

					.personal-info {
						flex: 1;

						.personal-row {
							margin-bottom: .5rem;
							display: flex;
							font-size: .875rem;

							&:last-child {
								margin-bottom: 0;
							}

							.info-label {
								color: #666;
								width: 3.4375rem;
							}

							.info-value {
								flex: 1;
								color: #333;

								&:empty::after {
									content: '请填写';
									color: #aaa;
								}
							}
						}
					}
				}
			}

			.intention-section {
				.intention-info {
					.intention-row {
						margin-bottom: .5rem;
						font-size: .875rem;
						color: #333;

						&:last-child {
							margin-bottom: 0;
						}
					}
				}
			}

			.education-section,
			.work-section,
			.project-section {

				.education-row,
				.work-row,
				.project-row {
					padding: .5rem 0;
					border-bottom: .0625rem solid #f5f5f5;

					&:last-child {
						border-bottom: none;
					}

					.education-school,
					.work-company,
					.project-name {
						font-size: .9375rem;
						font-weight: 500;
						color: #333;
						margin-bottom: .25rem;
					}

					.education-details,
					.work-details {
						padding: .75rem 0;
						display: flex;
						flex-direction: column;
						gap: .5rem;
					}

					.education-details,
					.work-details,
					.project-details {
						display: flex;
						flex-wrap: wrap;
						gap: .5rem;
						font-size: .8125rem;
						color: #666;
					}
				}
			}

			.skills-section {
				.skills-list {
					display: flex;
					flex-wrap: wrap;
					gap: .5rem;

					.skill-tag {
						padding: .25rem .625rem;
						background-color: #f0f9ff;
						color: #409eff;
						border-radius: .25rem;
						font-size: .8125rem;
					}
				}
			}

			.evaluation-section {
				.evaluation-text {
					font-size: .875rem;
					color: #333;
					line-height: 1.5;
				}
			}

			.bottomSafe {
				height: 70px;
			}

			.bottom {
				gap: 30rpx;
				position: fixed;
				bottom: 0;
				left: 0;
				right: 0;
				height: 70px;
				background-color: #fff;
				display: flex;
				align-items: center;
				justify-content: center;
				padding: 0 20px;
				box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
			}

			.preview-action {
				margin-top: 1.875rem;
				margin-bottom: 1.875rem;
				flex: 1;

				.preview-btn {
					width: 100%;
					height: 2.75rem;
					line-height: 2.75rem;
					background-color: #5ac725;
					color: #FFFFFF;
					font-size: 1rem;
					font-weight: 500;
					border-radius: 1.375rem;
					box-shadow: 0 .125rem .5rem rgba(90, 199, 37, 0.3);
				}
			}
		}
		.maxHeight {
			min-height: 50px;
			overflow-y: auto;
		}
	}
</style>